<!-- 
* @desc:消息管理搜索
* @fileName:MessageSearch.vue
* @author:chenxiaofeng@yzbdl.ac.cn
* @date:2022-5-24
!-->
<script setup lang="ts">
import { ref } from "vue";
import { Search, Plus } from "@element-plus/icons-vue";
// 接受父组件传回
const props = defineProps({
  // 查询方法
  searchFunc: Function as any,
  // 事件管理方法
  eventSetDialogOpenFunc:Function as any,
  // 查询按钮动画
  isSearchLoading: {
    type: Boolean,
    default: false,
  },
  //弹窗显示方法
  dialogControlFunc: Function as any,
});
// 定义时间类型值
const eventType = ref("");
// 定义小心类型值
const messageType = ref("");
// 定义关键字值
const key = ref("");
// 定义时间范围
const time = ref("");

const eventOptions = [
  { label: "服务器回复正常", value: "服务器回复正常" },
  { label: "服务器异常", value: "服务器异常" },
];

const messageOptions = [
  { label: "通知", value: "通知" },
  { label: "告警", value: "告警" },
];

// 点击查询按钮
const serarch = () => {
  // 组装查询参数
  let serachData = {
    userValue: eventType.value,
    nickValue: messageType.value,
  };
  // 调用父组件传递的方法进行查询
  props.searchFunc(serachData);
};

// 点击添加按钮
const add = () => {
  //新增按钮
  props.dialogControlFunc("新增");
};

// 点击事件设置
const eventSet = () => {
  // 点击事件设置显示弹窗
  props.eventSetDialogOpenFunc();
}
</script>

<template>
  <div class="page-search">
    <!-- 列表文字 -->
    <div class="page-title-words">消息管理</div>
    <!-- 事件类型查询 -->
    <el-select
      class="page-search-eventChoose"
      v-model="eventType"
      placeholder="请选择事件类型"
      clearable
      @change="serarch"
      size="large"
    >
      <el-option
        v-for="item in eventOptions"
        :key="item.value"
        :label="item.label"
        :value="item.value"
      />
    </el-select>
    <!-- 消息类型查询 -->
    <el-select
      class="page-search-eventChoose"
      v-model="messageType"
      placeholder="请选择消息类型"
      clearable
      @change="serarch"
      size="large"
    >
      <el-option
        v-for="item in messageOptions"
        :key="item.value"
        :label="item.label"
        :value="item.value"
      />
    </el-select>
    <!-- 关键字查询 -->
    <el-input
      class="page-search-userInput"
      v-model="key"
      clearable
      :suffix-icon="Search"
      @clear="serarch"
      @keyup.enter.native="serarch"
      placeholder="请输入关键字"
    ></el-input>
    <!-- 时间范围查询 -->
    <div class="mr10">
      <el-date-picker
        v-model="time"
        format="YYYY/MM/DD"
        value-format="YYYY-MM-DD HH:mm:ss"
        type="daterange"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
      />
    </div>
    <el-button @click="eventSet" :icon="Plus">事件设置</el-button>
    <el-button @click="add" :icon="Plus">接受设置</el-button>
  </div>
</template>

<style scoped lang="scss">
.mr10{
  margin-right: 10px;
}
.page-search {
  display: flex;
  justify-content: flex-end;
  :deep(.el-date-editor--daterange) {
    border-radius: 0;
    background-color: #f2f2f6 !important;
    box-shadow: unset !important;
  }
  .page-search-eventChoose {
    width: 150px;
    margin-right: 10px;
  }
  :deep(.el-input__wrapper) {
    height: 30px;
    border-radius: 0;
    background-color: #f2f2f6 !important;
    box-shadow: unset !important;
  }
  .page-search-userInput {
    width: 200px;
    margin-right: 10px;
  }
  .page-title-words {
    font-size: 16px;
    color: #000;
    flex: 1;
  }
  .el-button {
    width: 100px;
    height: 30px;
    border-radius: 0;
    background-color: #f2f2f6;
    color: #000;
    border: 0;
    &:hover {
      background-color: #5473e6;
      color: #fff;
    }
  }
}
</style>
